From 1863c3b7b06d1e1f27553ec1da0011a5c738bbc5 Mon Sep 17 00:00:00 2001 From: tsteven4 Date: Mon, 9 Jul 2018 11:19:51 -0600 Subject: [PATCH] refactor cases of "Declarator is reassigned in all paths before being read" when the declarator and the subsequent assignment can be joined. --- an1.cc | 61 ++++++++++++++++------------------------------ an1sym.h | 6 ++--- arcdist.cc | 4 +-- bend.cc | 8 +++--- cet.cc | 3 +-- compegps.cc | 3 +-- cst.cc | 4 +-- csv_util.cc | 19 +++++---------- dmtlog.cc | 3 +-- explorist_ini.cc | 3 +-- formspec.cc | 3 +-- g7towin.cc | 3 +-- garmin_fs.cc | 8 ++---- garmin_gpi.cc | 3 +-- garmin_txt.cc | 3 +-- garmin_xt.cc | 44 ++++++++++++++------------------- globalsat_sport.cc | 3 +-- gpx.cc | 9 +++---- holux.cc | 3 +-- html.cc | 21 ++++++---------- humminbird.cc | 6 ++--- interpolate.cc | 3 +-- jtr.cc | 3 +-- kml.cc | 15 ++++-------- lowranceusr4.cc | 4 +-- magproto.cc | 3 +-- mapsend.cc | 3 +-- mapsource.cc | 4 +-- ozi.cc | 3 +-- polygon.cc | 7 ++---- psitrex.cc | 6 ++--- saroute.cc | 6 ++--- sbn.cc | 3 +-- skytraq.cc | 7 +++--- smplrout.cc | 6 ++--- stmsdf.cc | 3 +-- text.cc | 18 +++++--------- tomtom.cc | 4 +-- tpo.cc | 6 ++--- unicsv.cc | 6 ++--- v900.cc | 3 +-- vecs.cc | 6 ++--- vitosmt.cc | 46 ++++++++++++---------------------- vitovtt.cc | 6 ++--- wbt-200.cc | 6 ++--- wfff_xml.cc | 3 +-- xcsv.cc | 3 +-- xmltag.cc | 14 +++-------- 48 files changed, 140 insertions(+), 277 deletions(-) diff --git a/an1.cc b/an1.cc index 1471ce014..23ae46492 100644 --- a/an1.cc +++ b/an1.cc @@ -129,12 +129,11 @@ ReadString(gbfile* f, short len) static void ReadGuid(gbfile* f, GUID* guid) { - int i = 0; guid->l = ReadLong(f); - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { guid->s[i] = ReadShort(f); } - for (i = 0; i < 6; i++) { + for (int i = 0; i < 6; i++) { guid->c[i] = ReadChar(f); } } @@ -142,12 +141,11 @@ ReadGuid(gbfile* f, GUID* guid) static void WriteGuid(gbfile* f, GUID* guid) { - int i = 0; WriteLong(f, guid->l); - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { WriteShort(f, guid->s[i]); } - for (i = 0; i < 6; i++) { + for (int i = 0; i < 6; i++) { WriteChar(f, guid->c[i]); } } @@ -283,8 +281,7 @@ static void Copy_AN1_Waypoint(void** vdwpt, void* vwpt) static an1_waypoint_record* Alloc_AN1_Waypoint() { - an1_waypoint_record* result = nullptr; - result = (an1_waypoint_record*)xcalloc(sizeof(*result), 1); + an1_waypoint_record* result = (an1_waypoint_record*)xcalloc(sizeof(*result), 1); result->fs.type = FS_AN1W; result->fs.copy = Copy_AN1_Waypoint; result->fs.destroy = Destroy_AN1_Waypoint; @@ -309,8 +306,7 @@ static void Copy_AN1_Vertex(void** vdvert, void* vvert) static an1_vertex_record* Alloc_AN1_Vertex() { - an1_vertex_record* result = nullptr; - result = (an1_vertex_record*)xcalloc(sizeof(*result), 1); + an1_vertex_record* result = (an1_vertex_record*)xcalloc(sizeof(*result), 1); result->fs.type = FS_AN1V; result->fs.copy = Copy_AN1_Vertex; result->fs.destroy = Destroy_AN1_Vertex; @@ -339,8 +335,7 @@ static void Copy_AN1_Line(void** vdline, void* vline) static an1_line_record* Alloc_AN1_Line() { - an1_line_record* result = nullptr; - result = (an1_line_record*)xcalloc(sizeof(*result), 1); + an1_line_record* result = (an1_line_record*)xcalloc(sizeof(*result), 1); result->fs.type = FS_AN1L; result->fs.copy = Copy_AN1_Line; result->fs.destroy = Destroy_AN1_Line; @@ -684,15 +679,12 @@ static void Write_AN1_Bitmaps(gbfile* f) static void Read_AN1_Waypoints(gbfile* f) { - unsigned long count = 0; - unsigned long i = 0; - an1_waypoint_record* rec = nullptr; Waypoint* wpt_tmp; char* icon = nullptr; ReadShort(f); - count = ReadLong(f); - for (i = 0; i < count; i++) { - rec = Alloc_AN1_Waypoint(); + unsigned long count = ReadLong(f); + for (unsigned long i = 0; i < count; i++) { + an1_waypoint_record* rec = Alloc_AN1_Waypoint(); Read_AN1_Waypoint(f, rec); wpt_tmp = new Waypoint; @@ -832,18 +824,13 @@ static void Write_AN1_Waypoints(gbfile* f) static void Read_AN1_Lines(gbfile* f) { - unsigned long count = 0; - unsigned long i = 0; - unsigned long j = 0; - an1_line_record* rec = nullptr; - an1_vertex_record* vert = nullptr; route_head* rte_head; Waypoint* wpt_tmp; ReadShort(f); - count = ReadLong(f); - for (i = 0; i < count; i++) { - rec = Alloc_AN1_Line(); + unsigned long count = ReadLong(f); + for (unsigned long i = 0; i < count; i++) { + an1_line_record* rec = Alloc_AN1_Line(); Read_AN1_Line(f, rec); /* create route rec */ rte_head = route_head_alloc(); @@ -860,8 +847,8 @@ static void Read_AN1_Lines(gbfile* f) rte_head->rte_name = rec->name; fs_chain_add(&rte_head->fs, (format_specific_data*)rec); route_add_head(rte_head); - for (j = 0; j < (unsigned) rec->pointcount; j++) { - vert = Alloc_AN1_Vertex(); + for (unsigned long j = 0; j < (unsigned) rec->pointcount; j++) { + an1_vertex_record* vert = Alloc_AN1_Vertex(); Read_AN1_Vertex(f, vert); /* create route point */ @@ -903,9 +890,8 @@ Write_One_AN1_Line(const route_head* rte) { an1_line_record* rec; int local; - format_specific_data* fs = nullptr; - fs = fs_chain_find(rte->fs, FS_AN1L); + format_specific_data* fs = fs_chain_find(rte->fs, FS_AN1L); if (fs) { rec = (an1_line_record*)(void*)fs; @@ -1000,9 +986,8 @@ Write_One_AN1_Vertex(const Waypoint* wpt) { an1_vertex_record* rec; int local; - format_specific_data* fs = nullptr; - fs = fs_chain_find(wpt->fs, FS_AN1V); + format_specific_data* fs = fs_chain_find(wpt->fs, FS_AN1V); if (fs) { rec = (an1_vertex_record*)(void*)fs; @@ -1139,16 +1124,12 @@ static void Init_Road_Changes() { int count = 0; - char* strType = nullptr; - char* name = nullptr; - char* bar = nullptr; - char* copy = nullptr; Free_Road_Changes(); if (!road_changes || !road_changes[0]) { return; } - bar = strchr(road_changes, '!'); + char* bar = strchr(road_changes, '!'); while (bar) { count++; bar = strchr(bar+1, '!'); @@ -1162,16 +1143,16 @@ Init_Road_Changes() roadchanges[count].type = 0; roadchanges[count].name = nullptr; - copy = xstrdup(road_changes); + char* copy = xstrdup(road_changes); bar = copy; while (count) { count--; - name = bar; + char* name = bar; bar = strchr(name, '!'); *bar = '\0'; bar++; - strType = bar; + char* strType = bar; bar = strchr(strType, '!'); if (bar) { *bar = '\0'; diff --git a/an1sym.h b/an1sym.h index ee0e02e4e..5ccbab92b 100644 --- a/an1sym.h +++ b/an1sym.h @@ -710,8 +710,7 @@ static struct defguid { static int FindIconByName(const char* name, GUID* guid) { - unsigned int i = 0; - for (i = 0; i < (sizeof(default_guids)/sizeof(struct defguid)); i++) { + for (unsigned int i = 0; i < (sizeof(default_guids)/sizeof(struct defguid)); i++) { if (!case_ignore_strcmp(name, default_guids[i].name)) { memcpy(guid, &(default_guids[i].guid), sizeof(GUID)); return 1; @@ -722,8 +721,7 @@ static int FindIconByName(const char* name, GUID* guid) static int FindIconByGuid(GUID* guid, char** name) { - unsigned int i = 0; - for (i = 0; i < (sizeof(default_guids)/sizeof(struct defguid)); i++) { + for (unsigned int i = 0; i < (sizeof(default_guids)/sizeof(struct defguid)); i++) { if (!memcmp(guid, &default_guids[i].guid, sizeof(GUID))) { *name = const_cast(default_guids[i].name); return 1; diff --git a/arcdist.cc b/arcdist.cc index 0e2c19ec1..86145fcd5 100644 --- a/arcdist.cc +++ b/arcdist.cc @@ -125,8 +125,6 @@ void ArcDistanceFilter::process() arcpt2->latitude = arcpt2->longitude = BADVAL; while ((line = gbfgetstr(file_in))) { - int argsfound = 0; - fileline++; char* pound = strchr(line, '#'); @@ -138,7 +136,7 @@ void ArcDistanceFilter::process() } arcpt2->latitude = arcpt2->longitude = BADVAL; - argsfound = sscanf(line, "%lf %lf", &arcpt2->latitude, &arcpt2->longitude); + int argsfound = sscanf(line, "%lf %lf", &arcpt2->latitude, &arcpt2->longitude); if (argsfound != 2 && strspn(line, " \t\n") < strlen(line)) { warning(MYNAME ": Warning: Arc file contains unusable vertex on line %d.\n", fileline); diff --git a/bend.cc b/bend.cc index b40c752dc..d66525f49 100644 --- a/bend.cc +++ b/bend.cc @@ -56,7 +56,6 @@ Waypoint* BendFilter::create_wpt_dest(const Waypoint* wpt_orig, double lat_orig, double frac; double lat_dest; double long_dest; - Waypoint* wpt_dest = nullptr; distance = radtometers(distance); if (distance <= maxDist) { return nullptr; @@ -67,7 +66,7 @@ Waypoint* BendFilter::create_wpt_dest(const Waypoint* wpt_orig, double lat_orig, linepart(lat_orig, long_orig, lat_orig_adj, long_orig_adj, frac, &lat_dest, &long_dest); - wpt_dest = new Waypoint(*wpt_orig); + Waypoint* wpt_dest = new Waypoint(*wpt_orig); wpt_dest->latitude = DEG(lat_dest); wpt_dest->longitude = DEG(long_dest); @@ -113,7 +112,6 @@ void BendFilter::process_route(const route_head* route_orig, route_head* route_d double lat_orig_next = RAD(wpt_orig_next->latitude); double long_orig_next = RAD(wpt_orig_next->longitude); - Waypoint* wpt_dest_next = nullptr; if (is_small_angle(lat_orig, long_orig, lat_orig_prev, long_orig_prev, lat_orig_next, long_orig_next)) { @@ -126,8 +124,8 @@ void BendFilter::process_route(const route_head* route_orig, route_head* route_d route_add_wpt(route_dest, wpt_dest_prev); } - wpt_dest_next = create_wpt_dest(wpt_orig, - lat_orig, long_orig, lat_orig_next, long_orig_next); + Waypoint* wpt_dest_next = create_wpt_dest(wpt_orig, + lat_orig, long_orig, lat_orig_next, long_orig_next); if (wpt_dest_next != nullptr) { route_add_wpt(route_dest, wpt_dest_next); diff --git a/cet.cc b/cet.cc index 4e44ffcb8..9b2821f6a 100644 --- a/cet.cc +++ b/cet.cc @@ -153,9 +153,8 @@ cet_utf8_to_ucs4(const char* str, int* bytes, int* value) } else { unsigned char bits = 0xc0; unsigned char mask = 0xe0; - int len = 0; - for (len = 1; len <= 6; len++) { /* outer loop, test UTF-8 frame */ + for (int len = 1; len <= 6; len++) { /* outer loop, test UTF-8 frame */ if ((*cp & mask) == bits) { int i = len; while (i-- > 0) { diff --git a/compegps.cc b/compegps.cc index 362df191a..a5eb1dac6 100644 --- a/compegps.cc +++ b/compegps.cc @@ -400,13 +400,12 @@ compegps_data_read(void) route_head* track = nullptr; while ((buff = gbfgetstr(fin))) { - char* cin = buff; char* ctail; if ((line++ == 0) && fin->unicode) { cet_convert_init(CET_CHARSET_UTF8, 1); } - cin = lrtrim(buff); + char* cin = lrtrim(buff); if (strlen(cin) == 0) { continue; } diff --git a/cst.cc b/cst.cc index be13a32ff..3b2e12f2f 100644 --- a/cst.cc +++ b/cst.cc @@ -165,12 +165,10 @@ cst_data_read() Waypoint* wpt = nullptr; while ((buff = gbfgetstr(fin))) { - char* cin = buff; - if ((line++ == 0) && fin->unicode) { cet_convert_init(CET_CHARSET_UTF8, 1); } - cin = lrtrim(buff); + char* cin = lrtrim(buff); if (strlen(cin) == 0) { continue; } diff --git a/csv_util.cc b/csv_util.cc index 6bfcc9349..4f902cb78 100644 --- a/csv_util.cc +++ b/csv_util.cc @@ -191,7 +191,6 @@ char* csv_stringtrim(const char* string, const char* enclosure, int strip_max) { static const char* p1 = nullptr; - char* p2 = nullptr; char* tmp = xxstrdup(string,file,line); size_t elen; int stripped = 0; @@ -206,7 +205,7 @@ csv_stringtrim(const char* string, const char* enclosure, int strip_max) elen = strlen(enclosure); } - p2 = tmp + strlen(tmp) - 1; + char* p2 = tmp + strlen(tmp) - 1; p1 = tmp; /* trim off trailing whitespace */ @@ -638,17 +637,11 @@ human_to_dec(const char* instr, double* outlat, double* outlon, int which) QString dec_to_human(const char* format, const char* dirs, double val) { - char* subformat = nullptr; - const char* formatptr = nullptr; - char* percent = nullptr; - char* type = nullptr; - int index = 0; int intvals[3] = {0,0,0}; double dblvals[3] = {0,0,0}; - int sign = 0; - sign = (val < 0) ? 0 : 1; + int sign = (val < 0) ? 0 : 1; dblvals[0] = fabs(val); intvals[0] = (int)dblvals[0]; @@ -657,16 +650,16 @@ dec_to_human(const char* format, const char* dirs, double val) dblvals[2] = 60*(dblvals[1]-intvals[1]); intvals[2] = (int)dblvals[2]; - subformat = (char*) xmalloc(strlen(format)+2); - formatptr = format; + char* subformat = (char*) xmalloc(strlen(format)+2); + const char* formatptr = format; QString buff; while (formatptr && *formatptr) { strcpy(subformat, formatptr); - percent = strchr(subformat, '%'); + char* percent = strchr(subformat, '%'); if (percent) { - type = percent+1+strcspn(percent+1, "cdiouxXeEfgG%"); + char* type = percent+1+strcspn(percent+1, "cdiouxXeEfgG%"); *(type+1) = '\0'; switch (*type) { case 'c': diff --git a/dmtlog.cc b/dmtlog.cc index e68535074..b39f0a4b3 100644 --- a/dmtlog.cc +++ b/dmtlog.cc @@ -584,7 +584,6 @@ read_CTrackFile(const int version) static int inflate_buff(const char* buff, const size_t size, char** out_buff) { - int res = Z_OK; z_stream strm; char out[DEFLATE_BUFF_SIZE]; char* cout = nullptr; @@ -597,7 +596,7 @@ inflate_buff(const char* buff, const size_t size, char** out_buff) strm.avail_in = 0; strm.next_in = Z_NULL; - res = inflateInit(&strm); + int res = inflateInit(&strm); if (res != Z_OK) { return res; } diff --git a/explorist_ini.cc b/explorist_ini.cc index 472117a43..3db42ae5d 100644 --- a/explorist_ini.cc +++ b/explorist_ini.cc @@ -16,7 +16,6 @@ explorist_read_value(const char* section, const char* key) static mag_info* explorist_ini_try(const char* path) { - mag_info* info = nullptr; char* inipath; char* s; @@ -27,7 +26,7 @@ explorist_ini_try(const char* path) return nullptr; } - info = (mag_info*) xmalloc(sizeof(mag_info)); + mag_info* info = (mag_info*) xmalloc(sizeof(mag_info)); info->geo_path = nullptr; info->track_path = nullptr; info->waypoint_path = nullptr; diff --git a/formspec.cc b/formspec.cc index 1fcd1101d..331b69a97 100644 --- a/formspec.cc +++ b/formspec.cc @@ -39,9 +39,8 @@ format_specific_data* fs_chain_copy(format_specific_data* source) void fs_chain_destroy(format_specific_data* chain) { format_specific_data* cur = chain; - format_specific_data* next = nullptr; while (cur) { - next = cur->next; + format_specific_data* next = cur->next; cur->destroy(cur); cur = next; } diff --git a/g7towin.cc b/g7towin.cc index 16cfef3b6..ecf5620ac 100644 --- a/g7towin.cc +++ b/g7towin.cc @@ -416,14 +416,13 @@ data_read(void) route_head* head = nullptr; while ((buff = gbfgetstr(fin))) { - char* cin = buff; char* cdata; if ((line++ == 0) && fin->unicode) { cet_convert_init(CET_CHARSET_UTF8, 1); } - cin = lrtrim(buff); + char* cin = lrtrim(buff); if (!*cin) { continue; } diff --git a/garmin_fs.cc b/garmin_fs.cc index 18443b5e9..80d38f68f 100644 --- a/garmin_fs.cc +++ b/garmin_fs.cc @@ -36,9 +36,7 @@ garmin_fs_t* garmin_fs_alloc(const int protocol) { - garmin_fs_t* result = nullptr; - - result = (garmin_fs_t*)xcalloc(1, sizeof(*result)); + garmin_fs_t* result = (garmin_fs_t*)xcalloc(1, sizeof(*result)); result->fs.type = FS_GMSD; result->fs.copy = (fs_copy) garmin_fs_copy; result->fs.destroy = garmin_fs_destroy; @@ -432,9 +430,7 @@ garmin_fs_merge_category(const char* category_name, Waypoint* waypt) void garmin_fs_garmin_after_read(const GPS_PWay way, Waypoint* wpt, const int protoid) { - garmin_fs_t* gmsd = nullptr; - - gmsd = garmin_fs_alloc(protoid); + garmin_fs_t* gmsd = garmin_fs_alloc(protoid); fs_chain_add(&wpt->fs, (format_specific_data*) gmsd); /* nothing happens until gmsd is allocated some lines above */ diff --git a/garmin_gpi.cc b/garmin_gpi.cc index 5f0612168..8775da69c 100644 --- a/garmin_gpi.cc +++ b/garmin_gpi.cc @@ -283,7 +283,6 @@ gpi_read_string_old(const char* field) if (first == 0) { short l1; short l2; - char* res2 = nullptr; char lc1[3] = ""; char lc2[3] = ""; @@ -292,7 +291,7 @@ gpi_read_string_old(const char* field) char* res1 = gpi_read_lc_string_old(lc1, &l1); if ((l1 + 4) < l0) { // dual language? - res2 = gpi_read_lc_string_old(lc2, &l2); + char* res2 = gpi_read_lc_string_old(lc2, &l2); is_fatal((l1 + 4 + l2 + 4 != l0), MYNAME ": Error out of sync (wrong size %d/%d/%d) on field '%s'!", l0, l1, l2, field); if (opt_lang && (strcmp(opt_lang, lc1) == 0)) { diff --git a/garmin_txt.cc b/garmin_txt.cc index e084eb2b4..96585c46f 100644 --- a/garmin_txt.cc +++ b/garmin_txt.cc @@ -1108,12 +1108,11 @@ parse_waypoint() char* str; int column = -1; Waypoint* wpt; - garmin_fs_p gmsd = nullptr; bind_fields(waypt_header); wpt = new Waypoint; - gmsd = garmin_fs_alloc(-1); + garmin_fs_p gmsd = garmin_fs_alloc(-1); fs_chain_add(&wpt->fs, (format_specific_data*) gmsd); while ((str = csv_lineparse(nullptr, "\t", "", column++))) { diff --git a/garmin_xt.cc b/garmin_xt.cc index 9e5e2713b..0143078d0 100644 --- a/garmin_xt.cc +++ b/garmin_xt.cc @@ -87,7 +87,6 @@ static uint16_t format_garmin_xt_rd_st_attrs(char* p_trk_name, uint8_t* p_track_color) { int method = 0; - uint16_t trackbytes = 0, TrackPoints = 0; uint8_t spam = 0; int32_t TrackMaxLat = 0, TrackMaxLon = 0, TrackMinLat = 0, TrackMinLon = 0; char trk_name[30]=""; @@ -105,8 +104,8 @@ format_garmin_xt_rd_st_attrs(char* p_trk_name, uint8_t* p_track_color) // set to RED if not specified *p_track_color=9; - trackbytes = gbfgetuint16(fin); - TrackPoints = gbfgetuint16(fin); + uint16_t trackbytes = gbfgetuint16(fin); + uint16_t TrackPoints = gbfgetuint16(fin); (void) TrackPoints; switch (method) { @@ -171,8 +170,6 @@ format_garmin_xt_decrypt_trk_blk(int Count, uint8_t TrackBlock[]) static void format_garmin_xt_decomp_trk_blk(uint8_t ii, uint8_t TrackBlock[], double* Ele, double* Lat, double* Lon, uint32_t* Time) { - uint32_t LatLW = 0, LonLW = 0, TimeLW = 0; - double LatF = 0, LonF = 0; uint16_t PrevEleW; //printf("%d %d %d %d %d %d\n", TrackBlock[0], TrackBlock[1], TrackBlock[2], TrackBlock[3], TrackBlock[4], TrackBlock[5]); @@ -181,29 +178,29 @@ format_garmin_xt_decomp_trk_blk(uint8_t ii, uint8_t TrackBlock[], double* Ele, d PrevEleW = PrevEleW + TrackBlock[(ii - 1) * 12 ]; *Ele = (double)PrevEleW * GARMIN_XT_ELE - 1500; - LatLW = TrackBlock[(ii - 1) * 12 + 4]; + uint32_t LatLW = TrackBlock[(ii - 1) * 12 + 4]; LatLW = LatLW << 8; LatLW = LatLW + TrackBlock[(ii - 1) * 12 + 3]; LatLW = LatLW << 8; LatLW = LatLW + TrackBlock[(ii - 1) * 12 + 2]; - LatF = (double)LatLW; + double LatF = (double)LatLW; if (LatF > 8388608) { LatF = LatF - 16777216; } *Lat = LatF * 360 / 16777216; - LonLW = TrackBlock[(ii-1)*12+7]; + uint32_t LonLW = TrackBlock[(ii-1)*12+7]; LonLW = LonLW << 8; LonLW = LonLW+TrackBlock[(ii-1)*12+6]; LonLW = LonLW << 8; LonLW = LonLW+TrackBlock[(ii-1)*12+5]; - LonF = (double)LonLW; + double LonF = (double)LonLW; if (LonF>8388608) { LonF = LonF - 16777216; } *Lon = LonF * 360 / 16777216; - TimeLW = TrackBlock[(ii - 1) * 12 + 11]; + uint32_t TimeLW = TrackBlock[(ii - 1) * 12 + 11]; TimeLW = TimeLW << 8; TimeLW = TimeLW+TrackBlock[(ii - 1) * 12 + 10]; TimeLW = TimeLW << 8; @@ -234,8 +231,7 @@ static void format_garmin_xt_proc_strk() { int Count = 0; // Used to obtain number of read bytes - int NumberOfTracks = 0, TracksCompleted = 0; // Number of tracks in the file and number of processed tracks - uint16_t trackbytes = 0; // Bytes in track + int TracksCompleted = 0; // Number of tracks in the file and number of processed tracks uint8_t TrackBlock[STRK_BLOCK_SIZE + 1]; // File Block uint8_t ii; // temp variable double Lat = 0, Lon = 0; // wpt data @@ -248,7 +244,7 @@ format_garmin_xt_proc_strk() gbfseek(fin, 12, SEEK_SET); // read # of tracks - NumberOfTracks = gbfgetuint16(fin); + int NumberOfTracks = gbfgetuint16(fin); // Skip 2 bytes gbfseek(fin, 2, SEEK_CUR); @@ -261,7 +257,7 @@ format_garmin_xt_proc_strk() trk_name = (char*) xmalloc(30); // Generate Track Header - trackbytes = format_garmin_xt_rd_st_attrs(trk_name, &trk_color) - 50; + uint16_t trackbytes = format_garmin_xt_rd_st_attrs(trk_name, &trk_color) - 50; tmp_track = route_head_alloc(); // update track color @@ -338,10 +334,6 @@ format_garmin_xt_proc_strk() static void format_garmin_xt_proc_atrk() { - uint16_t block=0, uu=0; - uint32_t Lat=0, Lon=0; - uint32_t Tim=0; - double LatF = 0, LonF = 0, AltF = 0; Waypoint* wpt; int method = 0; unsigned char buf[3]; @@ -366,29 +358,29 @@ format_garmin_xt_proc_atrk() num_trackpoints = gbfgetuint32(fin); while (num_trackpoints--) { - block = gbfgetuint16(fin); + uint16_t block = gbfgetuint16(fin); if (block != 0x0c) { break; } gbfread(&buf, 3, DATABLOCKSIZE, fin); //1. Lat - Lat = buf[0] | (buf[1] << 8) | (buf[2] << 16); + uint32_t Lat = buf[0] | (buf[1] << 8) | (buf[2] << 16); gbfread(&buf, 3, DATABLOCKSIZE, fin); //2. Lon - Lon = buf[0] | (buf[1] << 8) | (buf[2] << 16); + uint32_t Lon = buf[0] | (buf[1] << 8) | (buf[2] << 16); - uu = gbfgetuint16(fin); - Tim = gbfgetuint32(fin); + uint16_t uu = gbfgetuint16(fin); + uint32_t Tim = gbfgetuint32(fin); Tim += 631065600; // adjustment to UnixTime - LatF = Lat; + double LatF = Lat; if (LatF>8388608) { LatF -= 16777216; }; - LonF = Lon; + double LonF = Lon; if (LonF>8388608) { LonF -= 16777216; }; - AltF = (double)uu * GARMIN_XT_ELE - 1500; + double AltF = (double)uu * GARMIN_XT_ELE - 1500; //create new waypoint wpt = new Waypoint; diff --git a/globalsat_sport.cc b/globalsat_sport.cc index 269fcbfbb..7b7bdcce0 100644 --- a/globalsat_sport.cc +++ b/globalsat_sport.cc @@ -576,8 +576,7 @@ track_read() uint8_t trackDeviceCommand; int track_length; - uint8_t* track_payload = nullptr; - track_payload = globalsat_read_package(&track_length, &trackDeviceCommand); + uint8_t* track_payload = globalsat_read_package(&track_length, &trackDeviceCommand); is_fatal(((track_length == 0) || (track_payload == nullptr)) , "tracklength in 0 bytes or payload nonexistant"); // printf("Got track package!!! Train data\n"); diff --git a/gpx.cc b/gpx.cc index d67f43f7c..4f90f7104 100644 --- a/gpx.cc +++ b/gpx.cc @@ -806,11 +806,9 @@ xml_parse_time(const QString& dateTimeString) int off_hr = 0; int off_min = 0; int off_sign = 1; - char* offsetstr = nullptr; - char* pointstr = nullptr; char* timestr = xstrdup(dateTimeString); - offsetstr = strchr(timestr, 'Z'); + char* offsetstr = strchr(timestr, 'Z'); if (offsetstr) { /* zulu time; offsets stay at defaults */ *offsetstr = '\0'; @@ -835,7 +833,7 @@ xml_parse_time(const QString& dateTimeString) } double fsec = 0; - pointstr = strchr(timestr, '.'); + char* pointstr = strchr(timestr, '.'); if (pointstr) { sscanf(pointstr, "%le", &fsec); #if 0 @@ -1455,7 +1453,6 @@ fprint_xml_chain(xml_tag* tag, const Waypoint* wpt) void free_gpx_extras(xml_tag* tag) { - xml_tag* next = nullptr; char** ap; while (tag) { @@ -1472,7 +1469,7 @@ void free_gpx_extras(xml_tag* tag) xfree(tag->attributes); } - next = tag->sibling; + xml_tag* next = tag->sibling; delete tag; tag = next; } diff --git a/holux.cc b/holux.cc index 46017dbe9..ae5e9a792 100644 --- a/holux.cc +++ b/holux.cc @@ -155,7 +155,6 @@ static const char* mknshort(const char* stIn,unsigned int sLen) #define MAX_STRINGLEN 255 static char strOut[MAX_STRINGLEN]; char strTmp[MAX_STRINGLEN]; - char* shortstr = nullptr; if (sLen > MAX_STRINGLEN) { return (stIn); @@ -168,7 +167,7 @@ static const char* mknshort(const char* stIn,unsigned int sLen) setshort_length(mkshort_handle, sLen); setshort_mustuniq(mkshort_handle, 0); - shortstr = mkshort(mkshort_handle, stIn); + char* shortstr = mkshort(mkshort_handle, stIn); strcpy(strTmp,shortstr); xfree(shortstr); diff --git a/html.cc b/html.cc index ee7907f4c..2e20c5950 100644 --- a/html.cc +++ b/html.cc @@ -85,7 +85,6 @@ html_disp(const Waypoint* wpt) int32_t utmz; double utme, utmn; char utmzc; - fs_xml* fs_gpx = nullptr; GPS_Math_WGS84_To_UTM_EN(wpt->latitude, wpt->longitude, @@ -151,22 +150,19 @@ html_disp(const Waypoint* wpt) gbfprintf(file_out, "

%s

\n", CSTRc(wpt->notes)); } - fs_gpx = nullptr; + fs_xml* fs_gpx = nullptr; if (includelogs) { fs_gpx = (fs_xml*)fs_chain_find(wpt->fs, FS_GPX); } if (fs_gpx && fs_gpx->tag) { xml_tag* root = fs_gpx->tag; - xml_tag* curlog = nullptr; - xml_tag* logpart = nullptr; - curlog = xml_findfirst(root, "groundspeak:log"); + xml_tag* curlog = xml_findfirst(root, "groundspeak:log"); while (curlog) { time_t logtime = 0; - struct tm* logtm = nullptr; gbfprintf(file_out, "

\n"); - logpart = xml_findfirst(curlog, "groundspeak:type"); + xml_tag* logpart = xml_findfirst(curlog, "groundspeak:type"); if (logpart) { gbfprintf(file_out, "%s by ", CSTR(logpart->cdata)); } @@ -181,7 +177,7 @@ html_disp(const Waypoint* wpt) logpart = xml_findfirst(curlog, "groundspeak:date"); if (logpart) { logtime = xml_parse_time(logpart->cdata).toTime_t(); - logtm = localtime(&logtime); + struct tm* logtm = localtime(&logtime); if (logtm) { gbfprintf(file_out, "%04d-%02d-%02d
\n", @@ -193,10 +189,9 @@ html_disp(const Waypoint* wpt) logpart = xml_findfirst(curlog, "groundspeak:log_wpt"); if (logpart) { - char* coordstr = nullptr; double lat = 0; double lon = 0; - coordstr = xml_attribute(logpart, "lat"); + char* coordstr = xml_attribute(logpart, "lat"); if (coordstr) { lat = atof(coordstr); } @@ -213,10 +208,8 @@ html_disp(const Waypoint* wpt) logpart = xml_findfirst(curlog, "groundspeak:text"); if (logpart) { - char* encstr = nullptr; - int encoded = 0; - encstr = xml_attribute(logpart, "encoded"); - encoded = (toupper(encstr[0]) != 'F'); + char* encstr = xml_attribute(logpart, "encoded"); + int encoded = (toupper(encstr[0]) != 'F'); QString s; if (html_encrypt && encoded) { diff --git a/humminbird.cc b/humminbird.cc index fa0d05f7c..63bd4192d 100644 --- a/humminbird.cc +++ b/humminbird.cc @@ -378,7 +378,6 @@ humminbird_read_track(gbfile* fin) humminbird_trk_point_t* points; route_head* trk; Waypoint* first_wpt; - int max_points = 0; int32_t accum_east; int32_t accum_north; double g_lat; @@ -401,7 +400,7 @@ humminbird_read_track(gbfile* fin) th.ne_east = be_read32(&th.ne_east); th.ne_north = be_read32(&th.ne_north); - max_points = (131080 - sizeof(uint32_t) - sizeof(th)) / sizeof(humminbird_trk_point_t); + int max_points = (131080 - sizeof(uint32_t) - sizeof(th)) / sizeof(humminbird_trk_point_t); if (th.num_points == max_points + 1) { th.num_points--; @@ -498,7 +497,6 @@ humminbird_read_track_old(gbfile* fin) humminbird_trk_point_old_t* points; route_head* trk; Waypoint* first_wpt; - int max_points = 0; int32_t accum_east; int32_t accum_north; double g_lat; @@ -521,7 +519,7 @@ humminbird_read_track_old(gbfile* fin) // These files are always 8048 bytes long. Note that that's the value // of the second 16-bit word in the signature. - max_points = (file_len - (sizeof(th) + sizeof(uint32_t) + TRK_NAME_LEN)) / sizeof(humminbird_trk_point_old_t); + int max_points = (file_len - (sizeof(th) + sizeof(uint32_t) + TRK_NAME_LEN)) / sizeof(humminbird_trk_point_old_t); if (th.num_points > max_points) { fatal(MYNAME ": Too many track points! (%d)\n", th.num_points); diff --git a/interpolate.cc b/interpolate.cc index c43b3fb25..219a238f4 100644 --- a/interpolate.cc +++ b/interpolate.cc @@ -55,7 +55,6 @@ void InterpolateFilter::process() } QUEUE_FOR_EACH(backuproute, elem, tmp) { - bool first = false; route_head* rte_old = (route_head*)elem; route_head* rte_new = route_head_alloc(); @@ -68,7 +67,7 @@ void InterpolateFilter::process() } else { track_add_head(rte_new); } - first = 1; + bool first = 1; QUEUE_FOR_EACH(&rte_old->waypoint_list, elem2, tmp2) { Waypoint* wpt = (Waypoint*)elem2; if (first) { diff --git a/jtr.cc b/jtr.cc index d85ede24d..21a6a84c1 100644 --- a/jtr.cc +++ b/jtr.cc @@ -106,7 +106,6 @@ jtr_read() Waypoint* wpt; struct tm tm; char* tmp; - int column = -1; char valid = 'V'; double lat, lon; float speed, course, mcourse, mvar, mdev; @@ -131,7 +130,7 @@ jtr_read() speed = course = mcourse = mvar = mdev = -1; mvardir = mdevdir = 0; - column = -1; + int column = -1; tmp = str; while ((str = csv_lineparse(tmp, ",", "", column++))) { tmp = nullptr; diff --git a/kml.cc b/kml.cc index 6602f4f8e..40968faf6 100644 --- a/kml.cc +++ b/kml.cc @@ -356,13 +356,12 @@ void wpt_ts_end(xg_string args, const QXmlStreamAttributes*) void wpt_coord(const QString& args, const QXmlStreamAttributes*) { - int n = 0; double lat, lon, alt; if (! wpt_tmp) { return; } // Alt is actually optional. - n = sscanf(CSTRc(args), "%lf,%lf,%lf", &lon, &lat, &alt); + int n = sscanf(CSTRc(args), "%lf,%lf,%lf", &lon, &lat, &alt); if (n >= 2) { wpt_tmp->latitude = lat; wpt_tmp->longitude = lon; @@ -1417,20 +1416,17 @@ static QString kml_geocache_get_logs(const Waypoint* wpt) QString r; fs_xml* fs_gpx = (fs_xml*)fs_chain_find(wpt->fs, FS_GPX); - xml_tag* root = nullptr; - xml_tag* curlog = nullptr; - xml_tag* logpart = nullptr; if (!fs_gpx) { return r; } - root = fs_gpx->tag; - curlog = xml_findfirst(root, "groundspeak:log"); + xml_tag* root = fs_gpx->tag; + xml_tag* curlog = xml_findfirst(root, "groundspeak:log"); while (curlog) { // Unless we have a broken GPX input, these logparts // branches will always be taken. - logpart = xml_findfirst(curlog, "groundspeak:type"); + xml_tag* logpart = xml_findfirst(curlog, "groundspeak:type"); if (logpart) { r = r + "

" + logpart->cdata + ""; } @@ -1450,9 +1446,8 @@ static QString kml_geocache_get_logs(const Waypoint* wpt) logpart = xml_findfirst(curlog, "groundspeak:text"); if (logpart) { - int encoded = 0; char* encstr = xml_attribute(logpart, "encoded"); - encoded = (toupper(encstr[0]) != 'F'); + int encoded = (toupper(encstr[0]) != 'F'); QString s; if (html_encrypt && encoded) { diff --git a/lowranceusr4.cc b/lowranceusr4.cc index 88b6657e9..310cf8fb5 100644 --- a/lowranceusr4.cc +++ b/lowranceusr4.cc @@ -115,9 +115,7 @@ lowranceusr4_readstr(char* buf, const int maxlen, gbfile* file, int bytes_per_ch static void lowranceusr4_writestr(const QString& buf, gbfile* file, unsigned int bytes_per_char) { - unsigned int len = 0; - - len = buf.length(); + unsigned int len = buf.length(); if (0xffffffff / bytes_per_char < len) { /* be pedantic and check for the unlikely event that we are asked diff --git a/magproto.cc b/magproto.cc index 3bcae258b..70725dec2 100644 --- a/magproto.cc +++ b/magproto.cc @@ -1438,11 +1438,10 @@ void mag_track_disp(const Waypoint* waypointp) int hms=0; int fracsec=0; int date=0; - struct tm* tm = nullptr; ilat = waypointp->latitude; ilon = waypointp->longitude; - tm = nullptr; + struct tm* tm = nullptr; if (waypointp->creation_time.isValid()) { const time_t ct = waypointp->GetCreationTime().toTime_t(); tm = gmtime(&ct); diff --git a/mapsend.cc b/mapsend.cc index 3d8938ccf..3827daf90 100644 --- a/mapsend.cc +++ b/mapsend.cc @@ -268,7 +268,6 @@ mapsend_read() static void mapsend_waypt_pr(const Waypoint* waypointp) { - unsigned int c = 0; double falt; static int cnt = 0; QString sn = global_opts.synthesize_shortnames ? @@ -296,7 +295,7 @@ mapsend_waypt_pr(const Waypoint* waypointp) // This is funny looking to ensure that no more than 30 bytes // get written to the file. - c = waypointp->description.length(); + unsigned int c = waypointp->description.length(); if (c > 30) { c = 30; } diff --git a/mapsource.cc b/mapsource.cc index 45a3c508e..3c8b5a4af 100644 --- a/mapsource.cc +++ b/mapsource.cc @@ -780,10 +780,8 @@ mps_waypoint_w_unique_wrapper(const Waypoint* wpt) static void mps_route_wpt_w_unique_wrapper(const Waypoint* wpt) { - Waypoint* wptfound = nullptr; - /* Search for this waypoint in the ones already written */ - wptfound = mps_find_wpt_q_by_name(&written_wpt_head, CSTRc(wpt->shortname)); + Waypoint* wptfound = mps_find_wpt_q_by_name(&written_wpt_head, CSTRc(wpt->shortname)); if (wptfound == nullptr) /* so, not a real wpt, so must check route wpts already written as reals */ { diff --git a/ozi.cc b/ozi.cc index abceebe51..d196a5ea1 100644 --- a/ozi.cc +++ b/ozi.cc @@ -869,10 +869,9 @@ ozi_waypt_pr(const Waypoint* wpt) QString description; QString shortname; int faked_fsdata = 0; - ozi_fsdata* fs = nullptr; int icon = 0; - fs = (ozi_fsdata*) fs_chain_find(wpt->fs, FS_OZI); + ozi_fsdata* fs = (ozi_fsdata*) fs_chain_find(wpt->fs, FS_OZI); if (!fs) { fs = ozi_alloc_fsdata(); diff --git a/polygon.cc b/polygon.cc index 08af16c7e..f5d89c6d6 100644 --- a/polygon.cc +++ b/polygon.cc @@ -230,18 +230,15 @@ void PolygonFilter::process() olat = olon = lat1 = lon1 = lat2 = lon2 = BADVAL; while ((line = gbfgetstr(file_in))) { - char* pound = nullptr; - int argsfound = 0; - fileline++; - pound = strchr(line, '#'); + char* pound = strchr(line, '#'); if (pound) { *pound = '\0'; } lat2 = lon2 = BADVAL; - argsfound = sscanf(line, "%lf %lf", &lat2, &lon2); + int argsfound = sscanf(line, "%lf %lf", &lat2, &lon2); if (argsfound != 2 && strspn(line, " \t\n") < strlen(line)) { warning(MYNAME diff --git a/psitrex.cc b/psitrex.cc index b485177e4..360ce89f7 100644 --- a/psitrex.cc +++ b/psitrex.cc @@ -504,8 +504,6 @@ psit_track_r(gbfile* psit_file, route_head**) unsigned int trk_num; struct tm tmTime; - time_t dateTime = 0; - route_head* track_head = nullptr; Waypoint* thisWaypoint; psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), ltrimEOL); @@ -518,7 +516,7 @@ psit_track_r(gbfile* psit_file, route_head**) rtrim(trkname); trk_num = 0; - track_head = nullptr; + route_head* track_head = nullptr; psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), wscomma); @@ -557,7 +555,7 @@ psit_track_r(gbfile* psit_file, route_head**) &(tmTime.tm_sec)); tmTime.tm_isdst = 0; - dateTime = mkgmtime(&tmTime); + time_t dateTime = mkgmtime(&tmTime); psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), whitespace); diff --git a/saroute.cc b/saroute.cc index d1cc2ff7d..a6b0e7eb6 100644 --- a/saroute.cc +++ b/saroute.cc @@ -130,7 +130,6 @@ my_read() struct ll mylatlon; uint16_t coordcount; route_head* track_head = nullptr; - route_head* old_track_head = nullptr; Waypoint* wpt_tmp; char* routename = nullptr; double seglen = 0.0; @@ -139,7 +138,6 @@ my_read() double totaldist = 0.0; double oldlat = 0; double oldlon = 0; - int first = 0; ReadShort(infile); /* magic */ version = ReadShort(infile); @@ -311,7 +309,7 @@ my_read() } } while (count) { - old_track_head = nullptr; + route_head* old_track_head = nullptr; ReadShort(infile); recsize = ReadLong(infile); record = ReadRecord(infile, recsize); @@ -359,7 +357,7 @@ my_read() coordcount--; } - first = 1; + int first = 1; while (coordcount) { double lat; diff --git a/sbn.cc b/sbn.cc index a8e225a71..4ef6eb4a0 100644 --- a/sbn.cc +++ b/sbn.cc @@ -240,8 +240,7 @@ decode_sbn_position(const unsigned char* buffer, Waypoint* waypt) static Waypoint* decode_sbn_record(unsigned char* buffer) { - Waypoint* waypt = nullptr; - waypt = new Waypoint; + Waypoint* waypt = new Waypoint; if (is_sbn_valid(buffer)) { waypt->fix = decode_sbn_mode(buffer + 3); diff --git a/skytraq.cc b/skytraq.cc index eba361d24..4c60e1652 100644 --- a/skytraq.cc +++ b/skytraq.cc @@ -486,7 +486,7 @@ skytraq_configure_logging() { // an0008-1.4.14: logs if // (dt > tmin & dd >= dmin & v >= vmin) | dt > tmax | dd > dmax | v > vmax - unsigned int tmin=6, tmax=3600, dmin=0, dmax=10000, nn=0; + unsigned int tmin=6, tmax=3600, dmin=0, dmax=10000; static uint8_t MSG_LOG_CONFIGURE_CONTROL[] = { 0x18, // message_id 0x00, 0x00, 0x0e, 0x10, // max_time: was 0x0000ffff (big endian!) @@ -501,7 +501,7 @@ skytraq_configure_logging() if (opt_configure_logging) { if (*opt_configure_logging) { - nn = sscanf(opt_configure_logging, "%u:%u:%u:%u", &tmin, &tmax, &dmin, &dmax); + unsigned int nn = sscanf(opt_configure_logging, "%u:%u:%u:%u", &tmin, &tmax, &dmin, &dmax); if (nn>3) { db(0, "Reconfiguring logging to: tmin=%u, tmax=%u, dmin=%u, dmax=%u\n", tmin, tmax, dmin, dmax); be_write32(MSG_LOG_CONFIGURE_CONTROL+5, tmin); @@ -1060,7 +1060,6 @@ skytraq_read_tracks() int opt_first_sector_val = atoi(opt_first_sector); int opt_last_sector_val = atoi(opt_last_sector); int multi_read_supported = 1; - uint8_t* buffer = nullptr; gbfile* dumpfile = nullptr; state_init(&st); @@ -1100,7 +1099,7 @@ skytraq_read_tracks() } } - buffer = (uint8_t*) xmalloc(SECTOR_SIZE*read_at_once+sizeof(SECTOR_READ_END)+6); + uint8_t* buffer = (uint8_t*) xmalloc(SECTOR_SIZE*read_at_once+sizeof(SECTOR_READ_END)+6); // m.ad/090930: removed code that tried reducing read_at_once if necessary since doesn't work with xmalloc if (opt_dump_file) { diff --git a/smplrout.cc b/smplrout.cc index 61fe33243..5aa984da7 100644 --- a/smplrout.cc +++ b/smplrout.cc @@ -95,22 +95,20 @@ void SimplifyRouteFilter::routesimple_waypt_pr(const Waypoint* wpt) void SimplifyRouteFilter::compute_xte(struct xte* xte_rec) { const Waypoint* wpt3 = xte_rec->intermed->wpt; - const Waypoint* wpt1 = nullptr; - const Waypoint* wpt2 = nullptr; double frac, reslat, reslon; /* if no previous, this is an endpoint and must be preserved. */ if (!xte_rec->intermed->prev) { xte_rec->distance = HUGEVAL; return; } - wpt1 = xte_rec->intermed->prev->wpt; + const Waypoint* wpt1 = xte_rec->intermed->prev->wpt; /* if no next, this is an endpoint and must be preserved. */ if (!xte_rec->intermed->next) { xte_rec->distance = HUGEVAL; return; } - wpt2 = xte_rec->intermed->next->wpt; + const Waypoint* wpt2 = xte_rec->intermed->next->wpt; if (xteopt) { xte_rec->distance = radtomiles(linedist( diff --git a/stmsdf.cc b/stmsdf.cc index 6aa568eaa..94f1d068b 100644 --- a/stmsdf.cc +++ b/stmsdf.cc @@ -177,13 +177,12 @@ static void finalize_tracks(void) { Waypoint** list; - int count = 0; queue* elem, *tmp; int index; route_head* track = nullptr; int trackno = 0; - count = 0; + int count = 0; QUEUE_FOR_EACH(&trackpts, elem, tmp) { count++; }; diff --git a/text.cc b/text.cc index 962034361..489e6a26a 100644 --- a/text.cc +++ b/text.cc @@ -174,15 +174,12 @@ text_disp(const Waypoint* wpt) if (fs_gpx && fs_gpx->tag) { xml_tag* root = fs_gpx->tag; - xml_tag* curlog = nullptr; - xml_tag* logpart = nullptr; - curlog = xml_findfirst(root, "groundspeak:log"); + xml_tag* curlog = xml_findfirst(root, "groundspeak:log"); while (curlog) { time_t logtime = 0; - struct tm* logtm = nullptr; gbfprintf(file_out, "\n"); - logpart = xml_findfirst(curlog, "groundspeak:type"); + xml_tag* logpart = xml_findfirst(curlog, "groundspeak:type"); if (logpart) { gbfputs(logpart->cdata, file_out); gbfputs(" by ", file_out); @@ -197,7 +194,7 @@ text_disp(const Waypoint* wpt) logpart = xml_findfirst(curlog, "groundspeak:date"); if (logpart) { logtime = xml_parse_time(logpart->cdata).toTime_t(); - logtm = localtime(&logtime); + struct tm* logtm = localtime(&logtime); if (logtm) { gbfprintf(file_out, "%4.4d-%2.2d-%2.2d\n", @@ -209,10 +206,9 @@ text_disp(const Waypoint* wpt) logpart = xml_findfirst(curlog, "groundspeak:log_wpt"); if (logpart) { - char* coordstr = nullptr; double lat = 0; double lon = 0; - coordstr = xml_attribute(logpart, "lat"); + char* coordstr = xml_attribute(logpart, "lat"); if (coordstr) { lat = atof(coordstr); } @@ -227,10 +223,8 @@ text_disp(const Waypoint* wpt) logpart = xml_findfirst(curlog, "groundspeak:text"); if (logpart) { - char* encstr = nullptr; - int encoded = 0; - encstr = xml_attribute(logpart, "encoded"); - encoded = (toupper(encstr[0]) != 'F'); + char* encstr = xml_attribute(logpart, "encoded"); + int encoded = (toupper(encstr[0]) != 'F'); QString s; if (txt_encrypt && encoded) { diff --git a/tomtom.cc b/tomtom.cc index b5d90050d..929e2193e 100644 --- a/tomtom.cc +++ b/tomtom.cc @@ -373,12 +373,10 @@ compute_blocks(struct hdr* start, int count, newblock->maxlat = maxlat; newblock->size = 4 * 5 + 1; /* hdr is 5 longs, 1 char */ if (count < 20) { - Waypoint* wpt = nullptr; - for (int i = 0; i < count; i++) { newblock->size += 4 * 3 + 1; /* wpt const part 3 longs, 1 char */ - wpt = start[i].wpt; + Waypoint* wpt = start[i].wpt; newblock->size += wpt->description.length() + 1; } } else { diff --git a/tpo.cc b/tpo.cc index c4c29a3cf..a8a4ff1c8 100644 --- a/tpo.cc +++ b/tpo.cc @@ -622,7 +622,6 @@ static void tpo_process_tracks() int lon = 0; route_head* track_temp; char rgb[7],bgr[7]; - int bbggrr = 0; // Allocate the track struct track_temp = route_head_alloc(); @@ -652,7 +651,7 @@ static void tpo_process_tracks() // RGB line_color expressed for html=rrggbb and kml=bbggrr - not assigned before 2012 sprintf(rgb,"%02x%02x%02x",styles[track_style].color[0],styles[track_style].color[1],styles[track_style].color[2]); sprintf(bgr,"%02x%02x%02x",styles[track_style].color[2],styles[track_style].color[1],styles[track_style].color[0]); - bbggrr = styles[track_style].color[2] << 16 | styles[track_style].color[1] << 8 | styles[track_style].color[0]; + int bbggrr = styles[track_style].color[2] << 16 | styles[track_style].color[1] << 8 | styles[track_style].color[0]; track_temp->line_color.bbggrr = bbggrr; // track texture (dashed=1, solid=0) mapped into opacity - not assigned before 2012 @@ -1191,7 +1190,6 @@ static void tpo_process_routes() // Read/process each route in the file // for (unsigned int ii = 0; ii < route_count; ii++) { - unsigned int name_length = 0; unsigned int waypoint_cnt; route_head* route_temp; @@ -1208,7 +1206,7 @@ static void tpo_process_routes() //UNKNOWN DATA LENGTH // Fetch name length - name_length = tpo_read_int(); + unsigned int name_length = tpo_read_int(); QString route_name; if (name_length) { gbfread(route_name, 1, name_length, tpo_file_in); diff --git a/unicsv.cc b/unicsv.cc index a7a57772f..69c2344eb 100644 --- a/unicsv.cc +++ b/unicsv.cc @@ -517,7 +517,6 @@ unicsv_fondle_header(QString s) { // TODO: clean up this back and forth between QString and char*. char* buf = nullptr; - char* cbuf_start = nullptr; const cet_cs_vec_t* ascii = &cet_cs_vec_ansi_x3_4_1968; /* us-ascii */ /* Convert the entire header to lower case for convenience. @@ -531,7 +530,7 @@ unicsv_fondle_header(QString s) } else if (s.contains('|')) { unicsv_fieldsep = "|"; } - cbuf_start = xstrdup(s.toLower()); + char* cbuf_start = xstrdup(s.toLower()); const char* cbuf = cbuf_start; /* convert the header line into native ascii */ @@ -628,7 +627,6 @@ unicsv_rd_deinit() static void unicsv_parse_one_line(char* ibuf) { - Waypoint* wpt = nullptr; int column; int utm_zone = -9999; double utm_easting = 0; @@ -652,7 +650,7 @@ unicsv_parse_one_line(char* ibuf) int ns = 1; int ew = 1; geocache_data* gc_data = nullptr; - wpt = new Waypoint; + Waypoint* wpt = new Waypoint; wpt->latitude = unicsv_unknown; wpt->longitude = unicsv_unknown; memset(&ymd, 0, sizeof(ymd)); diff --git a/v900.cc b/v900.cc index aaa680ebf..ee6e2e57e 100644 --- a/v900.cc +++ b/v900.cc @@ -211,7 +211,6 @@ v900_read() struct one_line_advanced_mode adv; char text[200]; /* used to read the header line, which is normal text */ } line; - int is_advanced_mode = 0; int lc = 0; route_head* track; @@ -226,7 +225,7 @@ v900_read() if (!fgets(line.text, sizeof(line), fin)) { fatal("v900: error reading header (first) line from input file\n"); } - is_advanced_mode = (nullptr != strstr(line.text,"PDOP")); /* PDOP field appears only in advanced mode */ + int is_advanced_mode = (nullptr != strstr(line.text,"PDOP")); /* PDOP field appears only in advanced mode */ v900_log("header line: %s",line.text); v900_log("is_advance_mode=%d\n",is_advanced_mode); diff --git a/vecs.cc b/vecs.cc index 4b9e83cc3..b33e01d6a 100644 --- a/vecs.cc +++ b/vecs.cc @@ -1535,10 +1535,9 @@ disp_vecs() { vecs_t** svp; int vc; - int i = 0; svp = sort_and_unify_vecs(&vc); - for (i=0; ivec->type == ff_type_internal) { continue; } @@ -1562,10 +1561,9 @@ disp_vec(const char* vecname) { vecs_t** svp; int vc; - int i = 0; svp = sort_and_unify_vecs(&vc); - for (i=0; iname, vecname)) { continue; } diff --git a/vitosmt.cc b/vitosmt.cc index 715780cd6..4ba5e3c71 100644 --- a/vitosmt.cc +++ b/vitosmt.cc @@ -68,21 +68,8 @@ rd_deinit() static void vitosmt_read() { - long version =0; - long subversion =0; - long check1 =-1; - long check2 =-2; - long check3 =-3; route_head* route_head =nullptr; - Waypoint* wpt_tmp =nullptr; - unsigned char* timestamp =nullptr; struct tm tmStruct; - double speed = 0.0; - double course = 0.0; - double pdop = 0.0; - unsigned char gpsfix = 0; - unsigned char gpsvalid = 0; - unsigned char gpssats = 0; int serial =0; @@ -90,13 +77,13 @@ vitosmt_read() /* * 24 bytes header */ - version = gbfgetint32(infile); /* 2 */ - subversion = gbfgetint32(infile); /* 1000 */ + long version = gbfgetint32(infile); /* 2 */ + long subversion = gbfgetint32(infile); /* 1000 */ count = gbfgetint32(infile); /* n */ - check1 = gbfgetint32(infile); /* 0 */ - check2 = gbfgetint32(infile); /* not sure */ + long check1 = gbfgetint32(infile); /* 0 */ + long check2 = gbfgetint32(infile); /* not sure */ (void) check2; // silence warning. - check3 = gbfgetint32(infile); /* n */ + long check3 = gbfgetint32(infile); /* n */ if (version!=vitosmt_version) { @@ -130,16 +117,16 @@ vitosmt_read() double latrad = gbfgetdbl(infile); /* WGS84 latitude in radians */ double lonrad = gbfgetdbl(infile); /* WGS84 longitude in radians */ double elev = gbfgetdbl(infile); /* elevation in meters */ - timestamp = ReadRecord(infile,5); /* UTC time yr/mo/dy/hr/mi */ + unsigned char* timestamp = ReadRecord(infile,5); /* UTC time yr/mo/dy/hr/mi */ double seconds = gbfgetdbl(infile); /* seconds */ - speed = gbfgetdbl(infile); /* speed in knots */ - course = gbfgetdbl(infile); /* course in degrees */ - pdop = gbfgetdbl(infile); /* dilution of precision */ - gpsfix = gbfgetc(infile); /* fix type x08,x10, x20 */ - gpsvalid = gbfgetc(infile); /* fix is valid */ - gpssats = gbfgetc(infile); /* number of sats */ + double speed = gbfgetdbl(infile); /* speed in knots */ + double course = gbfgetdbl(infile); /* course in degrees */ + double pdop = gbfgetdbl(infile); /* dilution of precision */ + unsigned char gpsfix = gbfgetc(infile); /* fix type x08,x10, x20 */ + unsigned char gpsvalid = gbfgetc(infile); /* fix is valid */ + unsigned char gpssats = gbfgetc(infile); /* number of sats */ - wpt_tmp = new Waypoint; + Waypoint* wpt_tmp = new Waypoint; wpt_tmp->latitude =DEG(latrad); wpt_tmp->longitude =DEG(lonrad); @@ -223,12 +210,11 @@ wr_deinit() static void vitosmt_waypt_pr(const Waypoint* waypointp) { - unsigned char* workbuffer =nullptr; size_t position =0; double seconds =0; ++count; - workbuffer = (unsigned char*) xcalloc(vitosmt_datasize,1); + unsigned char* workbuffer = (unsigned char*) xcalloc(vitosmt_datasize,1); WriteDouble(&workbuffer[position], RAD(waypointp->latitude)); position += sizeof(double); @@ -302,9 +288,7 @@ vitosmt_waypt_pr(const Waypoint* waypointp) static void vitosmt_write() { - unsigned char* workbuffer = nullptr; - - workbuffer = (unsigned char*) xcalloc(vitosmt_headersize,1); + unsigned char* workbuffer = (unsigned char*) xcalloc(vitosmt_headersize,1); count = 0; diff --git a/vitovtt.cc b/vitovtt.cc index 887bdc898..27ff8526b 100644 --- a/vitovtt.cc +++ b/vitovtt.cc @@ -57,13 +57,11 @@ rd_deinit() static void vitovtt_read() { - route_head* route_head= nullptr; - Waypoint* wpt_tmp = nullptr; struct tm tmStruct; memset(&tmStruct, 0, sizeof(tmStruct)); - route_head = route_head_alloc(); + route_head* route_head = route_head_alloc(); track_add_head(route_head); /* Read the header. */ @@ -90,7 +88,7 @@ vitovtt_read() int course = gbfgetint16(infile); int status = gbfgetint32(infile); - wpt_tmp = new Waypoint; + Waypoint* wpt_tmp = new Waypoint; wpt_tmp->latitude= scaled_lat / vitovtt_latitudescale; wpt_tmp->longitude= scaled_lon / vitovtt_longitudescale; diff --git a/wbt-200.cc b/wbt-200.cc index 2850474d7..ca6ce26a1 100644 --- a/wbt-200.cc +++ b/wbt-200.cc @@ -566,7 +566,6 @@ static int wbt200_data_chunk(struct read_state* st, const void* buf, int fmt) uint32_t tim; double lat, lon, alt; time_t rtim; - Waypoint* tpt = nullptr; const char* bp = (const char*) buf; size_t buf_used = fmt_version[fmt].reclen; @@ -595,7 +594,7 @@ static int wbt200_data_chunk(struct read_state* st, const void* buf, int fmt) st->route_head_ = nullptr; } - tpt = make_trackpoint(st, lat, lon, alt, rtim); + Waypoint* tpt = make_trackpoint(st, lat, lon, alt, rtim); if (nullptr == st->route_head_) { db(1, "New Track\n"); @@ -802,7 +801,6 @@ static int wbt201_data_chunk(struct read_state* st, const void* buf) uint16_t flags; double lat, lon, alt; time_t rtim; - Waypoint* tpt = nullptr; const char* bp = (const char*) buf; /* Zero records are skipped */ @@ -834,7 +832,7 @@ static int wbt201_data_chunk(struct read_state* st, const void* buf) st->route_head_ = nullptr; } - tpt = make_trackpoint(st, lat, lon, alt, rtim); + Waypoint* tpt = make_trackpoint(st, lat, lon, alt, rtim); if (nullptr == st->route_head_) { db(1, "New Track\n"); diff --git a/wfff_xml.cc b/wfff_xml.cc index 67ad63f30..7db6cea4b 100644 --- a/wfff_xml.cc +++ b/wfff_xml.cc @@ -150,11 +150,10 @@ static long tosscount=0; void wfff_e(xg_string, const QXmlStreamAttributes*) { - Waypoint* wpt_tmp =nullptr; char desc[255] ="\0"; if ((ap_hdop>=1)&&(ap_hdop<50)) { // Discard invalid GPS fix - wpt_tmp = new Waypoint; + Waypoint* wpt_tmp = new Waypoint; if (snmac) { wpt_tmp->shortname = ap_mac; diff --git a/xcsv.cc b/xcsv.cc index 5359fb61d..fb2dd951d 100644 --- a/xcsv.cc +++ b/xcsv.cc @@ -112,7 +112,6 @@ xcsv_destroy_style(void) { queue* elem, *tmp; field_map_t* fmp; - int internal = 0; /* * If this xcsv_file struct came from a file we can free it all. @@ -184,7 +183,7 @@ xcsv_destroy_style(void) } /* return everything to zeros */ - internal = xcsv_file.is_internal; + int internal = xcsv_file.is_internal; xcsv_file.is_internal = internal; } diff --git a/xmltag.cc b/xmltag.cc index 605b92eb6..c17916a9a 100644 --- a/xmltag.cc +++ b/xmltag.cc @@ -29,7 +29,6 @@ static void free_xml_tag(xml_tag* tag) { - xml_tag* next = nullptr; char** ap; while (tag) { @@ -46,7 +45,7 @@ free_xml_tag(xml_tag* tag) xfree(tag->attributes); } - next = tag->sibling; + xml_tag* next = tag->sibling; delete tag; tag = next; } @@ -56,15 +55,12 @@ free_xml_tag(xml_tag* tag) static void copy_xml_tag(xml_tag** copy, xml_tag* src, xml_tag* parent) { - xml_tag* res = nullptr; - char** ap = nullptr; - if (!src) { *copy = nullptr; return; } - res = new xml_tag; + xml_tag* res = new xml_tag; *copy = res; // memcpy(res, src, sizeof(xml_tag)); @@ -72,7 +68,7 @@ copy_xml_tag(xml_tag** copy, xml_tag* src, xml_tag* parent) res->cdata = (src->cdata); res->parentcdata = (src->parentcdata); if (src->attributes) { - ap = src->attributes; + char** ap = src->attributes; int count = 0; while (*ap) { count++; @@ -95,8 +91,6 @@ copy_xml_tag(xml_tag** copy, xml_tag* src, xml_tag* parent) static void convert_xml_tag(xml_tag* tag) { - char** ap = nullptr; - if (tag == nullptr) { return; } @@ -106,7 +100,7 @@ convert_xml_tag(xml_tag* tag) tag->cdata = tag->cdata; tag->parentcdata = tag->parentcdata; - ap = tag->attributes; + char** ap = tag->attributes; while (*ap) { *ap = cet_convert_string(*ap); ap++; -- 2.30.2